package com.hjh.core.scope

import com.elvishew.xlog.XLog
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob

/**
 * @author： hjh
 * @createDate： 2025/6/12 15:52
 * @description：
 * @qq： 3472903821
 * @version: 1.0
 */
object AppCoroutineScope : CoroutineScope {

    private val job = SupervisorJob()

    override val coroutineContext = job + Dispatchers.IO +
            CoroutineExceptionHandler { _, e ->
                XLog.tag("AppCoroutineScope").e("Coroutine failed", e)
            }

    fun cancelAll() = job.cancel()
}